import DS from 'ember-data';

export default DS.Model.extend({
  username: DS.attr('string'),
  email: DS.attr('string'),
  //DS.attr 可以设置默认值
  verified: DS.attr('boolean', { defaultValue: false }),
  createdAt: DS.attr('date', {
    defaultValue() { return new Date(); }
  }),
  queryRecord(store, type, query) {
    return $.getJSON('/api/current_user');
  },
  profile: DS.belongsTo('profile'),// one to one 
  bestFriend: DS.belongsTo('user', { inverse: 'bestFriend' }),
  //Polymorphism 多态性
  paymentMethods: DS.hasMany('payment-method', { polymorphic: true })
});